Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

355
Visualizações
Connect-flash message is not working for res.render("SomeView")

I am not able to use connect-flash package for res.render. My main aim is to display a flash message on rendering of a view.

I am able to make it work with a res.redirect("route") but not with the res.render("view") code. Is it by design ?

My code is shown as below

if(err){
      // Apparently res.render("register") didn't work with flash. But res.redirect("/register") worked.
        req.flash("error", err.message);   // Error occurs when the user is taken, password is empty etc.
        return res.redirect("/register");  // Short circut everything. Else the code below this would run as well and that would throw an error
    }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is the correct syntax for using req.flash with res.render:

req.flash('error', yourErrString);
res.render("register.ejs", {
   message: req.flash('error')
});
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda